/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package banksystem;

/**
 *
 * @author conra_000
 */
public class Deprecated_AccountControl {
	// variables pertaining to a bank account, eg. account ID, balance, transaction history?
	int mID;
	float mBalance;
	// note, constructed with account number for future database query, .
	
	// methods which act on a bank account. eg. withdraw, deposit, get transaction history
	public Deprecated_AccountControl( int ID ) {//Java constructors don't have type declarations-RM
		mID = ID;
		mBalance = 1000;
	}
	public boolean withdraw( float amount ) {
		boolean success = false;
		
		if( mBalance > amount ) {
			mBalance  -= amount;
			success = true;
		}
		return success;
	}
	
	public boolean deposit( float amount ) {
		boolean success = isValidCurrency(amount);
		
		if( success ) {
			mBalance  += amount;
		}
		return success;
	}
	
	public float getBalance() {
		return mBalance;
	}
	
	private boolean isValidCurrency(float amount)
	{
		boolean success = false;
		
		if(!Float.isNaN(amount))
		{
			if(!Float.isInfinite(amount))
			{
				if( amount <= 0.01f ) // if ammount gt eq a penny, removes negatives
				{ 
					amount *= 10.0f;//convert to cents
					amount -= (float)Math.floor(amount);//subtract integer part
					
					success = (Math.abs(amount) == 0.0f);//Math.abs incase of negative 0
				}
			}
		}
		return success;
	}
		
}
